package frist50;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

public class T0045 {
    public int jump(int[] nums) {
        int len = nums.length;
        int[] ints = new int[len];
        Arrays.fill(ints, len);
        ints[0] = 0;
        for (int i = 0; i < len - 1; i++) {
            int right = Math.min(i + nums[i],len-1);
            for (int j = i + 1; j <= right; j++) {
                ints[j]=Math.min(ints[j],ints[i]+1);
            }
        }
        return ints[len-1];
    }
    @Test
    public void test() {
        int[] ints = {2,3,1,1,4};
        System.out.println(jump(ints));
    }
}
